<!DOCTYPE html>
<html>
<?php echo $this->fetch('head.html'); ?>
<body>
<div class="body">
<div class="header">
    <a href="<?php echo $this->_var['appkucun']; ?>?m=index"  class="left-btn"><span class="iconfont icon-back"></span></a>
    <div class="title">产品管理</div>
    <a href="<?php echo $this->_var['appkucun']; ?>?m=kucun_product&a=add" class="right-btn"><span class="iconfont icon-upload"></span></a>
  </div>
<div class="main-body">
 <div class="tabs-border">
 	<a href="<?php echo $this->_var['appkucun']; ?>?m=kucun_product" class="item <?php if (get ( 'status' ) != 4): ?>active<?php endif; ?>">上线</a>
    <a href="<?php echo $this->_var['appkucun']; ?>?m=kucun_product&status=4" class="item <?php if (get ( 'status' ) == 4): ?>active<?php endif; ?>">下线</a>
 </div>
 <div class="plist">
  <?php $_from = $this->_var['data']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
  <div class="item" id="kc<?php echo $this->_var['c']['id']; ?>">
   
    
    	<div class="g-sd1">
        	<img src="<?php echo images_site($this->_var['c']['imgurl']); ?>.100x100.jpg">
        </div>
        <div class="g-mn1">
        	<div class="g-mn1c">
            	 <div class="title"><?php echo $this->_var['c']['title']; ?></div>
            	<div class="row-price">
               	 <span>价格￥<?php if ($this->_var['c']['lower_price'] > 0): ?><?php echo $this->_var['c']['lower_price']; ?><?php else: ?><?php echo $this->_var['c']['price']; ?> 元<?php endif; ?></span>
                 <span>库存：<span class="total_num"><?php echo $this->_var['c']['total_num']; ?></span></span>
                 <span>销量：<?php echo $this->_var['c']['buy_num']; ?></span>
                </div>
                
                
     
    <div class="tool">
     
    <?php if ($this->_var['c']['koudai'] == 0): ?>
    <?php if ($this->_var['c']['status'] == 2): ?>
    <a href="javascript:;" url="<?php echo $this->_var['appkucun']; ?>?m=kucun_product&a=forbid&ajax=1&id=<?php echo $this->_var['c']['id']; ?>" class="forbid">下线</a>
    <?php else: ?>
    <a href="javascript:;" url="<?php echo $this->_var['appkucun']; ?>?m=kucun_product&a=pass&ajax=1&id=<?php echo $this->_var['c']['id']; ?>" class="forbid">上线</a>
    <a href="javascript:;" url="<?php echo $this->_var['appkucun']; ?>?m=kucun_product&a=delete&ajax=1&id=<?php echo $this->_var['c']['id']; ?>" class="delete">删除</a>
    <?php endif; ?>
    
    <a href="javascript:;"  onClick="addKuCun(<?php echo $this->_var['c']['id']; ?>)">库存管理</a>
    <?php endif; ?> 
     </div>
            </div>
        </div>
   
    
    
  </div>
  <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
  </div>
  <?php if ($this->_var['pagelist']): ?>
  <div><?php echo $this->_var['pagelist']; ?></div>
    <?php endif; ?>
 

</div>
 

<?php echo $this->fetch('footer.html'); ?>
<script>
function addKuCun(id){
	$.get("<?php echo $this->_var['appkucun']; ?>?m=kucun_product&ajax=1&a=addkucun&id="+id,function(data){
		showbox("库存管理",data,200,60);
	});	
}

 

$(function(){
	$(document).on("click",".forbid",function(data){
		var obj=$(this);
		$.get($(this).attr("url"),function(data){
			if(data.error){
				skyToast(data.message);
			}else{
				obj.parents(".item").remove();
			}
		},"json")
	});
	
	$(document).on("click","#addKucun",function(data){
		var obj=$(this);
		$.get("<?php echo $this->_var['appkucun']; ?>?m=kucun_product&ajax=1&a=addkucunSave&id="+$("#kucun_id").val()+"&num="+$("#kucun_num").val(),function(data){
			if(data.error){
				skyToast(data.message);
				
			}else{
				 
				$("#kc"+data.data.id+" .total_num").html(data.data.total_num);
				showboxClose();
			}
			
		},"json");
	});
	
	 
});
</script>
</div>
</body>
</html>